package com.ctshk.sapp.system.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.system.dto.mian.data.MainDataDeductionRulesDTO;
import com.ctshk.rpc.system.dto.mian.data.MainDataTravelTipsDTO;
import com.ctshk.rpc.system.req.main.data.*;
import com.ctshk.rpc.system.service.IMainDataDeductionRulesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 退团扣费规则 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-26
 */
@Api(value = "退团扣费规则",tags = "退团扣费规则")
@RestController
@RequestMapping("/main/data/deduction/rules")
public class MainDataDeductionRulesController extends BaseController {

    /**
     * 退团规则服务
     */
    @DubboReference
    private IMainDataDeductionRulesService mainDataDeductionRulesService;

    @ApiOperation(value = "新增退团扣费规则信息", notes = "新增退团扣费规则信息")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增旅游小费规则信息", operDesc = "新增旅游小费规则信息")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataDeductionRulesReq req) {
        return mainDataDeductionRulesService.add(req, getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "编辑退团扣费规则信息", notes = "编辑退团扣费规则信息")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "编辑旅游小费规则信息", operDesc = "编辑旅游小费规则信息")
    @PostMapping("/update")
    public Result update(@RequestBody @Valid MainDataDeductionRulesUpdateReq req) {
        return mainDataDeductionRulesService.update(req, getCurrentUser(getRequest()));
    }


    @ApiOperation(value = "删除退团扣费规则信息", notes = "删除退团扣费规则信息")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.DELETE, operTitle = "删除旅游小费规则信息", operDesc = "删除旅游小费规则信息")
    @PostMapping("/delete")
    public Result delete(@RequestBody @Valid MainDataDeductionRulesIdReq req) {
        return mainDataDeductionRulesService.delete(req, getCurrentUser(getRequest()));

    }


    @ApiOperation(value = "查询退团扣费规则信息列表", notes = "查询退团扣费规则信息列表")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查询旅游小费规则信息", operDesc = "查询旅游小费规则信息")
    @PostMapping("/queryList")
    public Result<PageResponse<MainDataDeductionRulesDTO>> queryList(@RequestBody @Valid MainDataDeductionRulesQueryReq req) {
        return Result.success(mainDataDeductionRulesService.queryList(req));
    }


    @ApiOperation(value="设置状态接口（有效，无效）", notes="设置状态接口（有效，无效）")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "设置状态接口（有效，无效）", operDesc = "设置状态接口（有效，无效）")
    @PostMapping("/update/status")
    public Result updateStatus(@RequestBody @Valid MainDataDeductionRulesIdReq req) {
        return mainDataDeductionRulesService.updateStatus(req,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="查询退团扣费规则信息", notes="查询退团扣费规则信息")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查询退团扣费规则信息）", operDesc = "查询退团扣费规则信息")
    @PostMapping("/query")
    public Result<MainDataDeductionRulesDTO> query(@RequestBody @Valid MainDataDeductionRulesIdReq req) {
        return Result.success(mainDataDeductionRulesService.query(req));
    }

}
